#include "RegularOuter.h"
#include "ILevel.h"
#include "Record.h"
#include "Common.h"

namespace WLog
{
	RegularOuter::RegularOuter(std::ostream *pOs/* = &std::cout*/)
		: IOuter(pOs)
	{
		
	}
	
	RegularOuter::~RegularOuter()
	{
		
	}

	bool RegularOuter::outRecord(Record *pRecord, ILevel *pLevel)
	{
		if (!pLevel->callBack_BeforeOut(pRecord, this))
		{
			return false;
		}

		if (pLevel->bOutFileName())
		{
			out(pRecord->m_strFileName);
		}
		if (pLevel->bOutFuncName())
		{
			out(" : ");
			out(pRecord->m_strFuncName);
		}
		if (pLevel->bOutLineNo())
		{
			out("(Line:" + l2str(pRecord->m_nLine) + ") ");			
		}
		if (pLevel->bOutTime())
		{
			out(pRecord->m_strTime);
			outendl();
		}
		
		if (pLevel->bOutName())
		{
			out(pLevel->getName());
			out(" \t| ");
		}

		out(pRecord->m_strMsg);
		
		if (pLevel->bNewLine())
		{
			outendl();
		}
		
		return pLevel->callBack_AfterOut(pRecord, this);
	}


}
